package com.evil.formula.exception;

import com.evil.common.family.enums.RCodeEnum;
import com.evil.common.core.exception.BusinessException;
import com.evil.formula.enums.FormulaErrCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author liyang
 * @date 2023-10-30 17:53
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class FormulaException extends BusinessException {

    /**
     * 错误码
     */
    private Integer errCode;

    /**
     * 出错方法名称
     */
    private String funcName;
    /**
     * 类型错误参数索引，从0开始
     */
    private Integer paramIdx;
    /**
     * 正确情况下参数个数
     */
    private Integer expectNum;
    /**
     * 实际参数个数
     */
    private Integer actualNum;

    public FormulaException(FormulaErrCodeEnum codeEnum, String funcName, Integer paramIdx) {
        super(RCodeEnum.FORMULA_ERROR);
        this.errCode = codeEnum.getCode();
        this.funcName = funcName;
        this.paramIdx = paramIdx;
    }

    public FormulaException(FormulaErrCodeEnum codeEnum, String funcName, Integer expectNum, Integer actualNum) {
        super(RCodeEnum.FORMULA_ERROR);
        this.errCode = codeEnum.getCode();
        this.funcName = funcName;
        this.expectNum = expectNum;
        this.actualNum = actualNum;
    }
}
